<!DOCTYPE html>
<html>
    <head>
		<meta charset="utf-8">
		<title>技师迁证</title>
		<link rel="stylesheet" href="__ADMIN_PATH__/component/pear/css/pear.css" />
		<style>
			.expand.pear-btn:hover {
				color: currentColor;
                background: none;
			}
			.expand.pear-btn {
				border: 1px solid rgba(255, 255, 255, 0)
			}
		</style>
	</head>
	<body class="pear-container">
		<div class="layui-card">
			<div class="layui-card-body">
<!--				<form class="layui-form" action="">-->
<!--					<div class="layui-form-item">-->

<!--						<div class="layui-inline">-->
<!--							<label class="layui-form-label">等级名称</label>-->
<!--							<div class="layui-input-inline">-->
<!--								<input type="text" name="title" placeholder="" class="layui-input">-->
<!--							</div>-->
<!--						</div>-->

<!--						<div class="layui-inline" style="margin-left: 50px;">-->
<!--							<button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="search">-->
<!--								<i class="layui-icon layui-icon-search"></i>-->
<!--								查询-->
<!--							</button>-->
<!--							<button type="reset" class="pear-btn pear-btn-md">-->
<!--								<i class="layui-icon layui-icon-refresh"></i>-->
<!--								重置-->
<!--							</button>-->
<!--						</div>-->

<!--					</div>-->
<!--				</form>-->
			</div>
		</div>

		<div class="layui-card">
			<div class="layui-card-body">
				<table id="tableId" lay-filter="tableFilter"></table>
			</div>
		</div>

		<script src="__ADMIN_PATH__/component/layui/layui.js"></script>
		<script src="__ADMIN_PATH__/component/pear/pear.js"></script>
		<script>
			layui.use(['table', 'form', 'jquery','common', 'popup', 'loading'], function() {
				let table = layui.table;
				let form = layui.form;
				let $ = layui.jquery;
				let common = layui.common;
				var popup = layui.popup;
				let loading = layui.loading;

				let articleTable = table.render({
					elem: '#tableId',
					method: "post",
					url: "{:url('Technmove/index')}",
					limit: 20,
					page: true,
					even: true,
					skin: 'line',
					toolbar: "#toolbarTpl",
					cols: [[
						{type: "checkbox"},
						{field: "id", title: "ID", width: 100, sort: true, align: 'center'},
						{field: "techn_name", title: "技师名称", width: 150,},
						{field: "old", title: "原工作地", width: 250,},
						{field: "new", title: "新工作地", width: 250,},
						{field: "add_time_time", title: "申请时间", width: 150,},
						{field: "status_s", title: "状态", width: 150,},
						{field: "upd_time_time", title: "审核时间", width: 150,},

						{title: "操作", align: "center", toolbar: "#operationTpl"}
					]],
					done: function (res, curr, count) {
						console.log(res, curr, count)
					}
				});

				form.on('submit(search)', function (data) {
					articleTable.reload({
						where: data.field,
						page: {curr: 1}
					});
					return false;
				});

				table.on("toolbar(tableFilter)", function (obj) {
					switch (obj.event) {
						case "add":
							add();
							break;
					}
				});

				function add() {
					layer.open({
						type: 2,
						title: '新增',
						shade: 0.5,
						maxmin: true,
						area: [common.isModile() ? '100%' : '90%', common.isModile() ? '100%' : '90%'],
						content: "{:url('saveinfo')}"
					});
				}

				table.on("tool(tableFilter)", function (obj) {
					let data = obj.data;
					switch (obj.event) {
						case "agree":
							agree(data.id);
							break;

						case "disagree":
							disagree(data.id);
							break;
					}
				});

				function agree(id) {
					$.ajax({
						url: "{:url('Technmove/agree')}",
						type: "POST",
						dataType: "JSON",
						data: {
							id: id
						},
						success: function (res) {
							if (res.code == 0) {
								popup.success(res.msg);
								setTimeout(function(){
									location.reload();
								},2000)
							} else {
								popup.warning(res.msg);
							}
						},
						error: function () {

						}
					});
				}

				function disagree(id) {

					$.ajax({
						url: "{:url('Technmove/disagree')}",
						type: "POST",
						dataType: "JSON",
						data: {
							id: id
						},
						success: function (res) {
							if (res.code == 0) {
								popup.success(res.msg);
								setTimeout(function(){
									location.reload();
								},2000)
							} else {
								popup.warning(res.msg);
							}
						},
						error: function () {

						}
					});
				}
			});


		</script>

		<!-- 头工具栏模板 -->
<!--		<script type="text/html" id="toolbarTpl">-->
<!--			<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">-->
<!--		        <i class="layui-icon layui-icon-add-1"></i>-->
<!--		        新增-->
<!--		    </button>-->
<!--		</script>-->

		<!-- 行工具栏模板 -->
		<script type="text/html" id="operationTpl">
			{{# if(d.status == 0){ }}
			<button class="pear-btn pear-btn-primary pear-btn-sm" title="通过" lay-event="agree">通过</button>

			<button class="pear-btn pear-btn-danger pear-btn-sm" title="驳回" lay-event="disagree">驳回</button>
			{{# } }}
		</script>

		<!--等级-->
		<script type="text/html" id="levelTpl">
			{{d.title}}(v{{d.rank}})
		</script>
		<!--分成比例-->
		<script type="text/html" id="divide_intoTpl">
			{{d.divide_into}}%
		</script>
		<!--最低业绩-->
		<script type="text/html" id="low_resultTpl">
			{{# if(d.low_result <= 0){ }}
		    	无要求
		    {{# }else{ }}
		    	{{d.low_result}}
		    {{# } }}
		</script>
		<!--在线时长-->
		<script type="text/html" id="online_durationTpl">
			{{# if(d.online_duration <= 0){ }}
				无要求
			{{# }else{ }}
				{{d.online_duration}}H
			{{# } }}
		</script>
		<!--加钟率-->
		<script type="text/html" id="plus_clock_rateTpl">
			{{# if(d.plus_clock_rate <= 0){ }}
				无要求
			{{# }else{ }}
				{{d.plus_clock_rate}}%
			{{# } }}
		</script>
		<!--积分-->
		<script type="text/html" id="integralTpl">
			{{# if(d.integral <= 0){ }}
				无要求
			{{# }else{ }}
				{{d.integral}}
			{{# } }}
		</script>
		<!--加钟分成比例-->
		<script type="text/html" id="jz_blTpl">
			{{d.jz_bl}}%
		</script>
	</body>
</html>